package com.activenetwork.util.verification;

import org.openqa.selenium.WebElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.activenetwork.custom.uielement.decorate.IdentifierFactory;
import com.activenetwork.util.EnvContext;
import com.activenetwork.util.verification.gson.FailurePoint;

public class checkEnable implements VerificationAction {	
	private static Logger logger = LoggerFactory.getLogger(checkEnable.class);
	private String pageName;
	private String pageField;
	private String caseName;
	private WebElement element;
	
	
	public checkEnable(String pageName, String pageField, String caseName){
		this.pageName = pageName;
		this.pageField = pageField;
		this.caseName = caseName;
	}
	
	public checkEnable(WebElement element, String caseName){
		this.element = element;
		this.caseName = caseName;
	}
	
	@Override
	public void verify() {
		if(element == null){
			element = IdentifierFactory.createWebElement(pageName, pageField);
		}
		
		if(!element.isEnabled()){
			logger.error(pageName + "-" + pageField + " is not enabled");
			EnvContext.failurePointTL.get().add(
					new FailurePoint(caseName, "Verify Input Enable", pageName + "-" + pageField + " is not enabled"));
		}
	}

}
